home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / src / binutils.252 / ld / ldemul.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-18  |  3.6 KB  |  201 lines

  1. /* ldemul.c -- clearing house for ld emulation states
  2.    Copyright (C) 1991, 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GLD, the Gnu Linker.
  5.  
  6. GLD is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GLD is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GLD; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include "bfd.h"
  21. #include "sysdep.h"
  22.  
  23. #include "config.h"
  24. #include "ld.h"
  25. #include "ldemul.h"
  26. #include "ldmisc.h"
  27. #include "ldexp.h"
  28. #include "ldlang.h"
  29. #include "ldfile.h"
  30. #include "ldmain.h"
  31. #include "ldemul-list.h"
  32.  
  33. ld_emulation_xfer_type *ld_emulation;
  34.  
  35. void
  36. ldemul_hll(name)
  37.      char *name;
  38. {
  39.   ld_emulation->hll(name);
  40. }
  41.  
  42.  
  43. void ldemul_syslib(name)
  44.      char *name;
  45. {
  46.   ld_emulation->syslib(name);
  47. }
  48.  
  49. void
  50. ldemul_after_parse()
  51. {
  52.   ld_emulation->after_parse();
  53. }
  54.  
  55. void
  56. ldemul_before_parse()
  57. {
  58.   ld_emulation->before_parse();
  59. }
  60.  
  61. void 
  62. ldemul_after_allocation()
  63. {
  64.   ld_emulation->after_allocation();
  65. }
  66.  
  67. void 
  68. ldemul_before_allocation()
  69. {
  70.   if (ld_emulation->before_allocation)
  71.     ld_emulation->before_allocation();
  72. }
  73.  
  74.  
  75. void
  76. ldemul_set_output_arch()
  77. {
  78.   ld_emulation->set_output_arch();
  79. }
  80.  
  81. void
  82. ldemul_finish()
  83. {
  84.   if (ld_emulation->finish)
  85.     ld_emulation->finish();
  86. }
  87.  
  88. void
  89. ldemul_create_output_section_statements()
  90. {
  91.   if (ld_emulation->create_output_section_statements)
  92.     ld_emulation->create_output_section_statements();
  93. }
  94.  
  95. char *
  96. ldemul_get_script(isfile)
  97.      int *isfile;
  98. {
  99.   return ld_emulation->get_script(isfile);
  100. }
  101.  
  102. boolean
  103. ldemul_open_dynamic_archive (arch, entry)
  104.      const char *arch;
  105.      lang_input_statement_type *entry;
  106. {
  107.   if (ld_emulation->open_dynamic_archive)
  108.     return (*ld_emulation->open_dynamic_archive) (arch, entry);
  109.   return false;
  110. }
  111.  
  112. boolean
  113. ldemul_place_orphan (file, s)
  114.      lang_input_statement_type *file;
  115.      asection *s;
  116. {
  117.   if (ld_emulation->place_orphan)
  118.     return (*ld_emulation->place_orphan) (file, s);
  119.   return false;
  120. }
  121.  
  122. char *
  123. ldemul_choose_target()
  124. {
  125.   return ld_emulation->choose_target();
  126. }
  127.  
  128. /* The default choose_target function.  */
  129.  
  130. char *
  131. ldemul_default_target()
  132. {
  133.   char *from_outside = getenv(TARGET_ENVIRON);
  134.   if (from_outside != (char *)NULL)
  135.     return from_outside;
  136.   return ld_emulation->target_name;
  137. }
  138.  
  139. void 
  140. after_parse_default()
  141. {
  142.  
  143. }
  144.  
  145. void
  146. after_allocation_default()
  147. {
  148.  
  149. }
  150.  
  151. void
  152. before_allocation_default()
  153. {
  154.  
  155. }
  156.  
  157. void
  158. set_output_arch_default()
  159. {
  160.   /* Set the output architecture and machine if possible */
  161.   bfd_set_arch_mach(output_bfd,
  162.                 ldfile_output_architecture, ldfile_output_machine);
  163. }
  164.  
  165. /*ARGSUSED*/
  166. void
  167. syslib_default(ignore)
  168.      char  *ignore;
  169. {
  170.   info_msg ("%S SYSLIB ignored\n");
  171. }
  172.  
  173. /*ARGSUSED*/
  174. void
  175. hll_default(ignore)
  176.      char  *ignore;
  177. {
  178.   info_msg ("%S HLL ignored\n");
  179. }
  180.  
  181. ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST };
  182.  
  183. void
  184. ldemul_choose_mode(target)
  185.      char *target;
  186. {
  187.     ld_emulation_xfer_type **eptr = ld_emulations;
  188.     /* Ignore "gld" prefix. */
  189.     if (target[0] == 'g' && target[1] == 'l' && target[2] == 'd')
  190.     target += 3;
  191.     for (; *eptr; eptr++)
  192.       {
  193.     if (strcmp(target, (*eptr)->emulation_name) == 0)
  194.       {
  195.         ld_emulation = *eptr;
  196.         return;
  197.       }
  198.       }
  199.     einfo("%P%F: unrecognised emulation mode: %s\n",target);
  200. }
  201.